<!--
 * @FileDescription: 分析结果展示
 * @Author: 周沿江
 * @Date: 2021/6/25
 * @LastEditors: 周沿江
 -->

<template>
  <div>
    <el-row>
      <el-col :span="6">
        <div class="crumbs">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item>
              <i class="el-icon-lx-calendar"></i> 分析结果展示
            </el-breadcrumb-item>
            <el-breadcrumb-item> 分析结果报告</el-breadcrumb-item>
          </el-breadcrumb>

        </div>
      </el-col>
      <el-col :span="2" :offset="16">
        <a :href=dox_path>
          <el-button type="primary">生成报告</el-button>
        </a>
      </el-col>
    </el-row>
    <el-row :gutter="10" style="margin-top: 8px">
      <el-col :span="24">
        <el-card>
          <div style="font-weight: bolder;text-align: center;font-size: 25px"> 设备分析结果

          </div>

          <div style="font-weight: bolder;margin-left:55%;margin-top: 10px; font-size: 20px;color: #909399">基线风险等级:
            <el-tag v-if="baseline_info_result.securityCode==2" type="danger"
                    style="  font-size: 23px; color: rgba(245, 108, 108, 0.7)">高风险
            </el-tag>
            <el-tag v-if="baseline_info_result.securityCode==1" type="warning"
                    style="  font-size: 23px; color: rgba(230, 162, 60, 0.5)">中风险
            </el-tag>
            <el-tag v-if="baseline_info_result.securityCode==0" type="info"
                    style="  font-size: 23px; color: rgba(144, 147, 153, 0.5)">低风险
            </el-tag>
          </div>
          <div style="margin-left:56.5%;font-weight: bolder;color: #909399">|&nbsp;
            &nbsp;服务配置:
            <el-tag type="danger" style="  font-size: 16px;margin-right: 20px; color: rgba(245, 108, 108, 0.7)">
              {{ baseline_info_result.services }}
            </el-tag>
            账号配置:
            <el-tag type="warning" style="  font-size: 16px; color: rgba(230, 162, 60, 0.6)">
              {{ baseline_info_result.privilegeRights }}
            </el-tag>
            系统权限:
            <el-tag type="warning" style="  font-size: 16px; color: rgba(230, 162, 60, 0.6)">
              {{ baseline_info_result.systemAccess }}
            </el-tag>
          </div>
          <br>


          <el-row style="margin-left: 12%" :gutter="40">

            <el-col :span="9">
              <span style="font-size: 17px;margin-top: 3px;margin-left: 10%">
            检测时间
           <span
               style="margin-right: 75px;font-size:16px;color: #112326;font-family: 'DS-DIGIT'">{{ device_info.date }}</span>
          </span>
              <li style="font-size: 14px;margin-left: 5%;margin-top: 3px">设备编号：{{ device_info.deviceId }}</li>


              <li style="font-size: 14px;margin-left: 5%;margin-top: 3px">用户名：{{ device_info.username }}</li>
              <li style="font-size: 14px;margin-left: 5%;margin-top: 3px">是否有影子账户：{{ shadow_account.shadowAccount }}
              </li>
              <li style="font-size: 14px;margin-left: 5%;margin-top: 3px">映像劫持：
                <span v-for="im in image_hijack"> &nbsp;&nbsp;{{ im }}</span>
              </li>
            </el-col>
            <el-col :span="9" :offset="3">


            </el-col>

          </el-row>
          <li style="font-size: 14px;margin-left: 15%;margin-top: 3px">开放的端口：
            <el-row :gutter="3" style="margin-left: 3%">
              <el-col :span="2" v-for="port in port_info" :key="port">
                <tag v-if="port > 1023" type="PORT" :text="port"></tag>
                <tag v-else type="PORT2" :text="port"></tag>
              </el-col>
            </el-row>

          </li>
        </el-card>
      </el-col>
      <el-col :span="9" style="margin-top: 10px">
        <el-card class="card_title" style="height: 500px" :body-style="{padding:'5px'}" shadow="hidden">
          <div slot="header">
            系统基本信息
          </div>
          <div style="font-size: 15px;font-weight: bolder">
            &nbsp;系统版本: &nbsp;{{ base_info.caption }}<br>
            &nbsp;主机名称:&nbsp; {{ base_info.CSName }}<br>
            &nbsp;电脑型号:&nbsp; {{ base_info.model }}<br>
            &nbsp;内存大小:&nbsp; {{ base_info.totalPhysicalMemory }}<br>
            &nbsp;cpu型号:&nbsp; {{ base_info.cpuName }}<br>
            &nbsp;系统位数:&nbsp; {{ base_info.OSArchitecture }}<br>
            &nbsp;使用语言:&nbsp; {{ base_info.MUILanguages }}<br>
            &nbsp;序列号:&nbsp; &nbsp;{{ base_info.serialNumber }}<br>
            &nbsp;制造商:&nbsp;&nbsp; {{ base_info.manufacturer }}<br>
            &nbsp;网卡信息:
            <el-table
                :data="network_info"
                style="width: 100%">
              <el-table-column
                  prop="ipAddress"
                  label="IP地址"
                  width="180">
              </el-table-column>
              <el-table-column
                  prop="netMask"
                  label="子网掩码"
                  width="180">
              </el-table-column>
              <el-table-column
                  prop="mac"
                  label="MAC地址">
              </el-table-column>
            </el-table>
          </div>
        </el-card>

      </el-col>
      <el-col :span="15" style="margin-top: 10px">

        <el-card shadow="hidden" style="height: 500px" class="card_title" :body-style="{padding:'5px'}">
          <div slot="header">
            系统补丁历史
          </div>
          <el-table
              :data="patch_info"
              style="width: 100%">
            <el-table-column
                prop="HotFixID"
                label="补丁ID"
                width="180">
            </el-table-column>
            <el-table-column
                prop="InstallDate"
                label="更新时间"
            >
            </el-table-column>
            <el-table-column
                prop="Description"
                label="更新描述"
            >
            </el-table-column>
            <el-table-column
                prop="InstalledBy"
                label="更新人"
            >
            </el-table-column>
          </el-table>

        </el-card>
      </el-col>
      <el-row :gutter="10">
        <el-col :span="8" style="margin-top: 10px">

          <el-card shadow="hidden" style="height: 500px" class="card_title" :body-style="{padding:'5px'}">
            <div slot="header">
              开机自启动项
            </div>
            <el-table
                height="430px"
                :data="run_once_show"
                style="width: 100%">
              <el-table-column
                  prop="appName"
                  label="软件名称"
                  width="180">
              </el-table-column>
              <el-table-column
                  prop="path"
                  label="软件运行路径"
              >
              </el-table-column>

            </el-table>
          </el-card>
        </el-col>
        <el-col :span="16" style="margin-top: 10px">

          <el-card shadow="hidden" style="height: 500px" class="card_title" :body-style="{padding:'5px'}">
            <div slot="header">
              系统软件
            </div>
            <base_table ref="undo_task_table" :show_submit_button="'none'" :table_height="300"
                        :show_export_button="'none'"></base_table>

          </el-card>
        </el-col>
      </el-row>
      <el-card shadow="hidden" style="height: 750px" class="card_title" :body-style="{padding:'5px'}">
        <div slot="header">
          本地安全策略
        </div>
        <base_table ref="policy" :show_submit_button="'none'" :table_height="550"
                    :show_export_button="'none'"></base_table>

      </el-card>
    </el-row>


  </div>
</template>

<script>
import tag from "../../module/tag_NER";
import base_table from "../../module/base_table";

export default {
  name: 'basecharts',
  components: {
    tag, base_table
  },
  watch: {},
  computed: {


  },
  data() {
    return {
      column: [{
        "title": "应用名称",
        "field": "name",
        "addition": false,
      }],
      column2: [{
        "title": "策略名称",
        "field": "policy_name",
        "addition": false,
      }, {
        "title": "现有配置",
        "field": "current_val",
        "addition": false,
      }, {
        "title": "建议配置",
        "field": "propose_val",
        "addition": false,
      }, {
        "title": "是否符合策略",
        "field": "is",
        "addition": false,
      }, {
        "title": "加固策略",
        "field": "fortify_policy",
        "addition": false,
      }, {
        "title": "策略类型",
        "field": "verify",
        "addition": false,
      }, {
        "title": "安全策略说明",
        "field": "comment",
        "addition": false,
      }],
      url: '',
      dox_path: '',
      device_info: {},
      install_software: [],
      install_software_show: [],
      baseline_info: {},
      baseline_info_show: [],
      shadow_account: {},
      image_hijack: {},
      baseline_info_result: {},
      base_info: {},
      network_info: {},
      patch_info: {},
      run_once: {},
      run_once_show: [],
      port_info: {},
      a: [],
      comments: [],
      comments_show: [],
    };
  },
  created() {
    this.init()
  },
  methods: {
    /**
     * 数据初始化
     * @returns {Promise<void>}
     */
    async init() {
      this.device_info = this.$route.params.device_info;
      var json_name = await this.$http.get('/task/selectById', {id: this.device_info.id});
      this.dox_path = "/apis/jsonfile/" + json_name.split(".json")[0] + ".docx"
      var data = await this.$http.get('/jsonfile/' + json_name);
      this.install_software = data.install_software
      this.base_info = data.base_info
      this.network_info = data.network_info
      this.patch_info = data.patch_info
      this.run_once = data.run_once
      this.port_info = data.port_info
      this.baseline_info = data.baseline_info
      this.baseline_info_result = data.baseline_info_result
      this.shadow_account = data.shadow_account
      this.image_hijack = data.image_hijack
      var key = Object.keys(this.run_once)
      for (var i = 0; i < key.length; i++) {
        this.run_once_show.push({"appName": key[i], "path": this.run_once[key[i]]})
      }
      for (key in this.install_software) {
        this.install_software_show.push({"name": this.install_software[key]})
      }
      for (var i = 0; i < this.baseline_info.length; i++) {
        var a = this.baseline_info[i]
        this.baseline_info_show.push({
          "policy_name": a[1],
          "current_val": a[2],
          "propose_val": a[3],
          "is": a[4],
          "fortify_policy": a[5],
          "comment": a[6],
          "verify": a[7]
        })
      }
      this.baseline_info_result['total'] = 0;
      for (key in this.baseline_info_result) {
        this.baseline_info_result['total'] = this.baseline_info_result['total'] + this.baseline_info_result[key]
      }
      this.$refs.undo_task_table.init(this.install_software_show, this.column)
      this.$refs.policy.init(this.baseline_info_show, this.column2)
    },
  }
};
</script>
<style scoped>
</style>


